﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiViewport : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiViewport(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGiViewport_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiViewport obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiViewport()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiViewport(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGiViewport cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiViewport_cast(OdRxObject.getCPtr(pObj));
			OdGiViewport result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiViewport)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiViewport)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiViewport)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiViewport_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiViewport_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiViewport_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiViewport createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiViewport_createObject();
			OdGiViewport result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiViewport)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiViewport)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiViewport)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGeMatrix3d getModelToEyeTransform()
		{
			OdGeMatrix3d result = new OdGeMatrix3d(GlobalsPINVOKE.OdGiViewport_getModelToEyeTransform(this.swigCPtr), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGeMatrix3d getEyeToModelTransform()
		{
			OdGeMatrix3d result = new OdGeMatrix3d(GlobalsPINVOKE.OdGiViewport_getEyeToModelTransform(this.swigCPtr), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGeMatrix3d getWorldToEyeTransform()
		{
			OdGeMatrix3d result = new OdGeMatrix3d(GlobalsPINVOKE.OdGiViewport_getWorldToEyeTransform(this.swigCPtr), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGeMatrix3d getEyeToWorldTransform()
		{
			OdGeMatrix3d result = new OdGeMatrix3d(GlobalsPINVOKE.OdGiViewport_getEyeToWorldTransform(this.swigCPtr), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isPerspective()
		{
			bool result = GlobalsPINVOKE.OdGiViewport_isPerspective(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool doPerspective(OdGePoint3d point)
		{
			bool result = GlobalsPINVOKE.OdGiViewport_doPerspective(this.swigCPtr, OdGePoint3d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool doInversePerspective(OdGePoint3d point)
		{
			bool result = GlobalsPINVOKE.OdGiViewport_doInversePerspective(this.swigCPtr, OdGePoint3d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void getNumPixelsInUnitSquare(OdGePoint3d point, OdGePoint2d pixelDensity, bool bUsePerspective)
		{
			GlobalsPINVOKE.OdGiViewport_getNumPixelsInUnitSquare__SWIG_0(this.swigCPtr, OdGePoint3d.getCPtr(point), OdGePoint2d.getCPtr(pixelDensity), bUsePerspective);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void getNumPixelsInUnitSquare(OdGePoint3d point, OdGePoint2d pixelDensity)
		{
			GlobalsPINVOKE.OdGiViewport_getNumPixelsInUnitSquare__SWIG_1(this.swigCPtr, OdGePoint3d.getCPtr(point), OdGePoint2d.getCPtr(pixelDensity));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdGePoint3d getCameraLocation()
		{
			OdGePoint3d result = new OdGePoint3d(GlobalsPINVOKE.OdGiViewport_getCameraLocation(this.swigCPtr), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGePoint3d getCameraTarget()
		{
			OdGePoint3d result = new OdGePoint3d(GlobalsPINVOKE.OdGiViewport_getCameraTarget(this.swigCPtr), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGeVector3d getCameraUpVector()
		{
			OdGeVector3d result = new OdGeVector3d(GlobalsPINVOKE.OdGiViewport_getCameraUpVector(this.swigCPtr), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGeVector3d viewDir()
		{
			OdGeVector3d result = new OdGeVector3d(GlobalsPINVOKE.OdGiViewport_viewDir(this.swigCPtr), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual uint viewportId()
		{
			uint result = GlobalsPINVOKE.OdGiViewport_viewportId(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual short acadWindowId()
		{
			short result = GlobalsPINVOKE.OdGiViewport_acadWindowId(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void getViewportDcCorners(OdGePoint2d lowerLeft, OdGePoint2d upperRight)
		{
			GlobalsPINVOKE.OdGiViewport_getViewportDcCorners(this.swigCPtr, OdGePoint2d.getCPtr(lowerLeft), OdGePoint2d.getCPtr(upperRight));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool getFrontAndBackClipValues(out bool clipFront, out bool clipBack, out double front, out double back)
		{
			bool result = GlobalsPINVOKE.OdGiViewport_getFrontAndBackClipValues(this.swigCPtr, out clipFront, out clipBack, out front, out back);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double linetypeScaleMultiplier()
		{
			double result = GlobalsPINVOKE.OdGiViewport_linetypeScaleMultiplier(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double linetypeGenerationCriteria()
		{
			double result = GlobalsPINVOKE.OdGiViewport_linetypeGenerationCriteria(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool layerVisible(OdDbStub layerId)
		{
			bool result = GlobalsPINVOKE.OdGiViewport_layerVisible(this.swigCPtr, OdDbStub.getCPtr(layerId));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiContextualColors contextualColors()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGiViewport_contextualColors(this.swigCPtr);
			OdGiContextualColors result = (intPtr == IntPtr.Zero) ? null : new OdGiContextualColors(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
